home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_qt.idb / usr / freeware / include / Qt / qheader.h.z / qheader.h
Encoding:
C/C++ Source or Header  |  1998-10-28  |  3.3 KB  |  134 lines

  1. /****************************************************************************
  2. ** $Id: qheader.h,v 2.20 1998/07/03 00:09:48 hanord Exp $
  3. **
  4. ** Definition of QHeader widget class (table header)
  5. **
  6. ** Created : 961105
  7. **
  8. ** Copyright (C) 1992-1998 Troll Tech AS.  All rights reserved.
  9. **
  10. ** This file is part of Qt Free Edition, version 1.40.
  11. **
  12. ** See the file LICENSE included in the distribution for the usage
  13. ** and distribution terms, or http://www.troll.no/free-license.html.
  14. **
  15. ** IMPORTANT NOTE: You may NOT copy this file or any part of it into
  16. ** your own programs or libraries.
  17. **
  18. ** Please see http://www.troll.no/pricing.html for information about 
  19. ** Qt Professional Edition, which is this same library but with a
  20. ** license which allows creation of commercial/proprietary software.
  21. **
  22. *****************************************************************************/
  23.  
  24. #ifndef QHEADER_H
  25. #define QHEADER_H
  26.  
  27. #ifndef QT_H
  28. #include "qtableview.h"
  29. #endif // QT_H
  30.  
  31. struct QHeaderData;
  32.  
  33. class QHeader : public QTableView
  34. {
  35.     Q_OBJECT
  36. public:
  37.     enum Orientation { Horizontal, Vertical };
  38.  
  39.     QHeader( QWidget *parent=0, const char *name=0 );
  40.     QHeader( int, QWidget *parent=0, const char *name=0 );
  41.     ~QHeader();
  42.  
  43.     int        addLabel( const char *, int size = -1 );
  44.     void    setLabel( int, const char *, int size = -1 );
  45.     const char*    label( int );
  46.     void    setOrientation( Orientation );
  47.     Orientation orientation() const;
  48.     void    setTracking( bool enable );
  49.     bool    tracking() const;
  50.  
  51.     void     setClickEnabled( bool, int logIdx = -1 );
  52.     void    setResizeEnabled( bool, int logIdx = -1 );
  53.     void    setMovingEnabled( bool );
  54.  
  55.     void    setCellSize( int i, int s );
  56.     int        cellSize( int i ) const;
  57.     int        cellPos( int i ) const;
  58.     int        cellAt( int i ) const;
  59.     int        count() const;
  60.  
  61.     int     offset() const;
  62.  
  63.     QSize    sizeHint() const;
  64.  
  65.     int        mapToLogical( int ) const;
  66.     int        mapToActual( int ) const;
  67.  
  68. public slots:
  69.     void    setOffset( int );
  70.  
  71. signals:
  72.     void    sectionClicked( int );
  73.     void    sizeChange( int section, int oldSize, int newSize );
  74.     void    moved( int from, int to );
  75. protected:
  76.     //    void    timerEvent( QTimerEvent * );
  77.  
  78.     void    resizeEvent( QResizeEvent * );
  79.  
  80.     QRect    sRect( int i );
  81.  
  82.     void    paintCell( QPainter *, int, int );
  83.     void    setupPainter( QPainter * );
  84.  
  85.     int        cellHeight( int );
  86.     int        cellWidth( int );
  87.  
  88.     void    mousePressEvent( QMouseEvent * );
  89.     void    mouseReleaseEvent( QMouseEvent * );
  90.     void    mouseMoveEvent( QMouseEvent * );
  91.  
  92. private:
  93.     void    init( int );
  94.  
  95.     void    paintRect( int p, int s );
  96.     void    markLine( int idx );
  97.     void    unMarkLine( int idx );
  98.     int        pPos( int i ) const;
  99.     int        pSize( int i ) const;
  100.  
  101.     int     findLine( int );
  102.  
  103.     void    handleColumnResize(int, int, bool);
  104.  
  105.     void    moveAround( int fromIdx, int toIdx );
  106.  
  107.     int        handleIdx;
  108.     int        oldHIdxSize;
  109.     int        moveToIdx;
  110.     enum State { Idle, Sliding, Pressed, Moving, Blocked };
  111.     State    state;
  112.     QCOORD    clickPos;
  113.     bool    trackingIsOn;
  114.  
  115.     Orientation orient;
  116.  
  117.     QHeaderData *data;
  118.  
  119. private:    // Disabled copy constructor and operator=
  120.     QHeader( const QHeader & );
  121.     QHeader &operator=( const QHeader & );
  122. };
  123.  
  124.  
  125. inline QHeader::Orientation QHeader::orientation() const
  126. {
  127.     return orient;
  128. }
  129.  
  130. inline void QHeader::setTracking( bool enable ) { trackingIsOn = enable; }
  131. inline bool QHeader::tracking() const { return trackingIsOn; }
  132.  
  133. #endif //QHEADER_H
  134.